package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.JieSuanWay;
import com.gxa.pojo.ShouRuType;
import com.gxa.service.shezhiservice.JiLiangDanWei46Service;
import com.gxa.service.shezhiservice.JieSuanWay46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @Author x
 */
@RestController
@RequestMapping("/JieSuanWay")
@Api(value = "结算方式管理" , tags = "结算方式数据接口API")
@RequiresPermissions("结算方式")
public class JieSuanWayController {

    @Autowired(required = false)
    public R r;
    @Autowired(required = false)
    public JieSuanWay46Service jieSuanWay46Service;

    @GetMapping("/selectAllJieSuanForPage")
    @ApiOperation(value = "结算查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R selectAllJieSuanWayForPage(@RequestParam int page,@RequestParam int size)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("jjj");
//        r.setData(list);
//        return r;
        return jieSuanWay46Service.selectAllJieSuanWayForPage(page , size);
    }

    @PostMapping("/insertJieSuanWay")
    @ApiOperation(value = "新增结算接口",notes="提供结算信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertJieSuanWay(@RequestBody JieSuanWay way)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        JieSuanWay jieSuan = new JieSuanWay();
//        jieSuan.setId(8);
//        list.add(jieSuan);
//        r.setData(list);
//        return r;
        return jieSuanWay46Service.insertJieSuanWay(way);
    }

    @PostMapping("/updateJieSuanWayById")
    @ApiOperation(value = "修改结算信息接口",notes="提供结算信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateJieSuanWayById(@RequestBody JieSuanWay way)
    {
//        r.setCode(200);
//        r.setMsg("修改成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        JieSuanWay jieSuan = new JieSuanWay();
//        jieSuan.setId(8);
//        list.add(jieSuan);
//        r.setData(list);
//        return r;
        return jieSuanWay46Service.updateJieSuanWayById(way);
    }

    @PostMapping("/deleteJieSuanWayById")
    @ApiOperation(value = "删除结算接口",notes = "提供结算id",httpMethod = "post",response = R.class)
    @ApiImplicitParam(name="id",value = "主键",required = true,dataType = "int")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteJieSuanWayById(@RequestParam int id)
    {
//        r.setCode(200);
//        r.setMsg("删除成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        JieSuanWay jieSuan = new JieSuanWay();
//        jieSuan.setId(8);
//        list.add(jieSuan);
//        r.setData(list);
//        return r;
        return jieSuanWay46Service.deleteJieSuanWayById(id);
    }


}
